package org.particlethink.auth;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;

public class UserInfoAuthenticationToken extends UsernamePasswordAuthenticationToken {

    private final DefaultUser user;
    private final String token;

    public UserInfoAuthenticationToken(DefaultUser user, String token) {
        super(user.getUsername(), user.getPassword(), user.getAuthorities());
        this.user = user;
        this.token = token;
    }

    @Override
    public Object getCredentials() {
        return token;
    }

    @Override
    public Object getDetails() {
        return user.getUser().getUserId();
    }

    @Override
    public Object getPrincipal() {
        return user;
    }
}
